'use strict';

const fn_index = async (ctx, next) => {
    ctx.response.body = `
        <form action="/login" method="post" >
            <p><input type="text" name="name" /></p>
            <p><input type="password" name="password" /></p>
            <p><input type="submit" value="submit" /></p>
        </from>
    `
}

const fn_login = async (ctx, next) => {
    const {name, password} = ctx.request.body;
    
    const res = ctx.response
    if (name === '111' && password === '111') {
        res.body = '<p>login success</p>'
    } else {
        res.body = '<a href="/">try again</a>'
    }
}

module.exports = {
    'GET /': fn_index,
    'POST /login': fn_login
}
